package com.tangtanwei.hotel.controller;

import com.tangtanwei.hotel.entity.Order;
import com.tangtanwei.hotel.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private HttpSession session;

    // 查找所有订单
    @RequestMapping("/getAllOrder")
    public List<Order> getAllUser(){
        return orderService.list();
    }

    // 保存或者修改订单信息
    @RequestMapping("/updateOrder")
    public String saveOrUpdateUser(Order order){
        return orderService.saveOrUpdateS(order);

    }

    //根据订单id删除订单
    @RequestMapping("/delete")
    public String deleteUserById(String id){
       return orderService.deleteOrderById(id);
    }

    // 搜索订单
    @RequestMapping("/searchOrder")
    public List<Order> searchOrder(String keyword){
        return  orderService.searchOrder(keyword);
    }

    // 根据订单状态获取所有订单
    @RequestMapping("/getOrderByStatus")
    public List<Order> getOrderByStatus(String status){
        return  orderService.getAllByConfitionField(0,status);
    }

    //  根据订单类型获取所有订单
    @RequestMapping("/getOrderByType")
    public List<Order> getOrderByType(String type){
        return  orderService.getAllByConfitionField(1,type);
    }

    // todo 查看订单详情


}
